//
//  NetWorkTools.swift
//  WeiBoSwift
//
//  Created by Jacky Sun on 16/4/27.
//  Copyright © 2016年 syf. All rights reserved.
//

import UIKit
import AFNetworking

class NetWorkTools: NSObject {
    
    class func  FD_Get_AfnRequest(urlString: String, parameters:[String: String], success: ( task: NSURLSessionDataTask, resulst: [String: AnyObject]) ->Void , failrue: (task: NSURLSessionDataTask, error: NSError ) ->Void) ->(){
        
        // 创建请求管理对象
        let manage: AFHTTPSessionManager? = AFHTTPSessionManager()
        // manage?.responseSerializer = AFHTTPResponseSerializer()
        // 设置AFN能够接收得数据类型
        manage!.responseSerializer.acceptableContentTypes = NSSet(objects: "application/json", "text/json", "text/javascript", "text/plain") as? Set<String>
    
        
        manage?.POST(urlString, parameters: parameters, success: { (t, Json) ->Void in
            
            success(task: t, resulst: Json as! [String: AnyObject])
            
            }, failure: { (t, error) ->Void in
                
                failrue(task: t!, error: error)
        })
        
        
      
    }
    
}
